part of '../repository.dart';

const _kLinkUserIdKey = 'user_id';
const _kLinkGooglePlayUserIdKey = 'google_play_user_id';

class _LinkDto extends Equatable {
  const _LinkDto._internal({
    required this.userId,
    required this.googlePlayUserId,
  });

  final String userId;
  final String googlePlayUserId;

  @override
  List<Object?> get props {
    return [
      userId,
      googlePlayUserId,
    ];
  }

  factory _LinkDto.fromJson(Map<String, dynamic> json) {
    return _LinkDto._internal(
      userId: json[_kLinkUserIdKey],
      googlePlayUserId: json[_kLinkGooglePlayUserIdKey],
    );
  }

  factory _LinkDto.fromEntity(GooglePlayUserToUserLink userLink) {
    return _LinkDto._internal(
      userId: userLink.userId,
      googlePlayUserId: userLink.googlePlayUserId,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      _kLinkUserIdKey: userId,
      _kLinkGooglePlayUserIdKey: googlePlayUserId,
    };
  }

  GooglePlayUserToUserLink toEntity() {
    return GooglePlayUserToUserLink(
      userId: userId,
      googlePlayUserId: googlePlayUserId,
    );
  }
}
